<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
<script src="<%=contextPath%>/js/zDialog.js"></script>
<script src="<%=contextPath%>/js/zDrag.js"></script>
<title>${demand.positionName}_${company.name}</title>
</head>
<body>
	<div class="container-fluid" id="main-container">
	    <input type="hidden" id="id" value="${demand.id}">
	    <input type="hidden" id="companyId" value="${company.id}">
	    <input type="hidden" id="name" value="${company.name}">
		<div id="page-content" class="clearfix">
			<div class="row-fluid">
				<div class="col-sm-12" style="margin-top: 20px;">
					<div class="col-sm-6" style="padding-left: 50px;line-height:30px;">
						<h3 ><i class="icon-user"></i> 招聘信息</h3>
					</div>
					<div class="col-sm-6" style="padding-right: 50px;float: right;text-align: right;">
						<div class="form-group">
						    <a id="addcontact" class="btn btn-primary" onclick="addcontact();">添加企业联系人</a>
						    <a class="btn btn-info" onclick="showcontact();">企业联系人列表</a>
							<%-- <a href="<%=contextPath%>/company/list" class="btn btn-info">返回列表</a> --%>
						</div>
					</div>
				</div>
				<div class="col-sm-12">
					<table border="1" class="table table-bordered">
						<tbody>
							<tr>
								<td width="15%">
									<p align="right">公司名称:</p>
								</td>
								<td width="15%">
									<p><a onclick="opencompany()" title="公司详情">${company.name }</a></p>
								</td>
								<td width="15%">
									<p align="right">公司简称:</p>
								</td>
								<td width="15%">
									<p>${company.shortName }</p>
								</td>
								<td width="15%">
									<p align="right">公司性质:</p>
								</td >
								<td width="15%">
									<p>${fns:getDictLabel(company.nature,'company_nature','')}</p>
								</td>
								<td width="15%">
									<p align="right">公司网址:</p>
								</td>
								<td width="15%">
									<p><a href="${company.website }" target="_blank" title="点击打开">${company.website }</a></p>
								</td>
							</tr>
							<tr>
								<td>
									<p align="right">联系人:</p>
								</td>
								<td>
									<p>${contact.resume.trueName}</p>
								</td>
								<td>
									<p align="right">联系电话:</p>
								</td>
								<td>
									<p>${contact.resume.cellphone}</p>
								</td>
								<td>
									<p align="right">岗位职能:</p>
								</td>
								<td>
									<p>${demand.positionNames}</p>
								</td>
								<td>
									<p align="right">岗位名称:</p>
								</td>
								<td>
									<p>${demand.positionName}</p>
								</td>
							</tr>
							<tr>
								<td>
									<p align="right">需求人数:</p>
								</td>
								<td>
									<p>${demand.demandNum}</p>
								</td>
								<td>
									<p align="right">岗位产生原因:</p>
								</td>
								<td>
									<p>${demand.cause}</p>
								</td>
								<td>
									<p align="right">工作区域:</p>
								</td>
								<td>
									<p>${demand.workAreaNames}</p>
								</td>
								<td>
									<p align="right">性别:</p>
								</td>
								<td>
									<p><c:if test="${demandEnterprise.sex eq 1 }">男</c:if><c:if test="${demandEnterprise.sex eq 2 }">女</c:if></p>
								</td>
							</tr>
							<tr>
								<td>
									<p align="right">主要职责:</p>
								</td>
								<td>
									<p>${demand.mainDuty}</p>
								</td>
								<td>
									<p align="right">核心任职要求:</p>
								</td>
								<td>
									<p>${demand.coreRequire}</p>
								</td>
								<td>
									<p align="right">汇报上级:</p>
								</td>
								<td>
									<p>${demand.reportSuperiors}</p>
								</td>
								<td>
									<p align="right">直接下属:</p>
								</td>
								<td>
									<p>${demand.underling}</p>
								</td>
							</tr>
							<tr>
							    <td>
									<p align="right">年龄区间:</p>
								</td>
								<td>
									<p>${demand.startAge }-${demandEnterprise.endAge }(岁)</p>
								</td>
								<td>
									<p align="right">最佳年龄:</p>
								</td>
								<td>
									<p>${demand.optimalAge}</p>
								</td>
								<td>
									<p align="right">学历:</p>
								</td>
								<td>
									<p>${demand.education}</p>
								</td>
								<td>
									<p align="right">统招:</p>
								</td>
								<td>
									<p><c:if test="${demandEnterprise.unified eq 1 }">是</c:if><c:if test="${demandEnterprise.unified eq 2 }">否</c:if></p>
								</td>
							</tr>
							<tr>
								<td>
									<p align="right">薪酬范围:</p>
								</td>
								<td>
									<p>${demand.startSalary }-${demandEnterprise.endSalary }(万人民币)</p>
								</td>
								<td>
									<p align="right">薪酬结构:</p>
								</td>
								<td>
									<p>${demand.salaryStructure}</p>
								</td>
								<td>
									<p align="right">对标企业经历:</p>
								</td>
								<td>
									<p>${demand.standardEnterprise}</p>
								</td>
								<td>
									<p align="right">排除企业工作的人:</p>
								</td>
								<td>
									<p>${demand.excludePerson}</p>
								</td>
							</tr>
						</tbody>
					</table>

				</div>
			</div>
			<div class="row-fluid">
				<div class="col-sm-12">
					<div class="col-sm-6" style="padding-left: 50px;line-height:30px;">
						<h3 ><i class="icon-external-link"></i> 推荐记录(<font color="red">${recommends_count}</font>)</h3>
					</div>
					<div class="col-sm-6" style="padding-right: 50px;float: right;text-align: right;">
						<div class="form-group">
							<button type="button" class="btn-sm btn-info" onclick="addrecommend();">添加</button>
						</div>
					</div>
				</div>
				<div class="col-sm-12">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>岗位名称</th>
								<th>候选人姓名</th>
								<th>推荐意见</th>
								<th>推荐时间</th>
								<th>推荐人</th>
								<th>推荐状态</th>
								<th>沟通记录</th>
								<th>是否通过</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
						<c:forEach items="${recommends }" var="recommend">
						   <tr>
								<td><a onclick="showdemand(&quot;${recommend.demandId}&quot;)" title="岗位详情">${recommend.dEnterprise.positionName }</a></td>
								<td><a class="J_menuItem" href="<%=contextPath%>/resume/detailView?id=${recommend.talentsId}" title="人才详情" target="_blank">${recommend.resume.trueName}</a></td>
								<td>${recommend.reason}</td>
								<td>${recommend.createDate}</td>
								<td>${recommend.createUser.truename}</td>
								<td><a onclick="openresult(&quot;${recommend.id}&quot;);" class="btn-sm btn-warning">${fns:getDictLabel(recommend.status,'rec_status','')}</a></td>
								<td><a onclick="openrecord(&quot;${recommend.id}&quot;);" class="btm-sm btn-link">查看详请</a></td>
								<td>
								     <c:if test="${recommend.isPast eq 0}"><span class='label label-default'>未反馈</span></c:if>
								     <c:if test="${recommend.isPast eq 1}"><span class='label label-success'>是</span></c:if>
								     <c:if test="${recommend.isPast eq 2}"><span class='label label-danger'>否</span></c:if>
								</td>
								<td>
									<a class="btn-sm btn-warning" onclick="addrecommend();">继续推荐</a>&nbsp;&nbsp;
									<a class="btn-sm btn-info" onclick="downreport(&quot;${recommend.reportFile }&quot;);">下载</a>&nbsp;&nbsp;
									<c:if test="${recommend.isPast eq 0}">
									<a class="btn-sm btn-primary" onclick="addfeedback(&quot;${recommend.id}&quot;,&quot;${recommend.talentsId}&quot;);">反馈结果</a>
									</c:if>
									<a class="btn-sm btn-info" onclick="timeline(&quot;${recommend.id }&quot;);">沟通环节</a>
								</td>
							</tr>
						</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<div class="row-fluid">
				<div class="col-sm-12">
					<div class="col-sm-6" style="padding-left: 50px;line-height:30px;">
						<h3 ><i class="icon-comments"></i> 沟通记录(<font color="red">${communicates_count}</font>)</h3>
					</div>
					<div class="col-sm-6" style="padding-right: 50px;float: right;text-align: right;">
						<!-- <div class="form-group">
							<button type="button" class="btn-sm btn-info" onclick="addcommunicate();">添加</button>
						</div> -->
					</div>
				</div>
				<div class="col-sm-12">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>姓名</th>
								<th>联系方式</th>
								<th>沟通方式</th>
								<th>沟通目的</th>
								<th>意向性</th>
								<th>沟通内容</th>
								<th>沟通时间</th>
								<th>沟通人</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
						<c:forEach items="${communicates }" var="communicate">
							<tr>
								<td>${communicate.resume.trueName }</td>
								<td>${communicate.resume.cellphone }</td>
								<td>${communicate.methods }</td>
								<td>${communicate.purpose }</td>
								<td>${communicate.intentionality }</td>
								<td>${communicate.details }</td>
								<td>${communicate.communicationTime }</td>
								<td>${communicate.user.truename }</td>
								<td>
								   <a class="btn-sm btn-warning" onclick="addcommunicate(&quot;${communicate.telentsId}&quot;);">继续沟通</a>&nbsp;&nbsp;
								   <a class="btn-sm btn-danger" onclick="feedback(&quot;${communicate.telentsId}&quot;);">结果反馈</a>
								</td>
							</tr>
						</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			</div>
				<!-- PAGE CONTENT ENDS HERE -->

			</div>
			<!--/row-->
		</div>
		<!--/#page-content-->
	</div>
	<!--/.fluid-container#main-container-->
	<script type="text/javascript">
	var id = $("#id").val();
	var companyId = $("#companyId").val();
	var companyName = $("#name").val();
	var postion ="${demand.positionName}";
	function opencompany() {
		window.open("<%=contextPath%>/company/detailView?id=" + companyId);
	}
	$(function () {
		$("#addcontact").click(function () {
			openwindow("添加企业联系人", "<%=contextPath%>/company/addContactView?demandId=" + id +"&companyId=" + companyId, 600, 750);
		})
	})
	function adddemand() {
		openwindow("添加招聘需求", "<%=contextPath%>/demandEnterprise/addView?companyId=" + companyId +"&tops=1", 600, 750);
	}
	function editdemand(id) {
		openwindow("修改招聘需求", "<%=contextPath%>/demandEnterprise/editView?id=" + id, 900, 750);
	}
	function addrecommend() {
		openwindow("新增人才推荐", "<%=contextPath%>/talentsRecommend/addView?demandId=" + id +"&companyId=" + companyId+"&position="+postion, 600, 750);
	}
	function addcontract() {
		openwindow("新增合同", "<%=contextPath%>/tbContract/addView?companyId=" + companyId +"&companyName="+companyName, 600, 750);
	}
	function editcontract(id) {
		openwindow("修改合同", "<%=contextPath%>/tbContract/editView?id=" + id, 600, 750);
	}
	function addcommunicate(resumeId) {
		openwindow("添加沟通", "<%=contextPath%>/demandCommunicate/addView?demandId="+id+"&talentsId="+resumeId+"&companyId=" + companyId, 600, 750);
	}
	function editrecommend(id) {
		openwindow("修改人才推荐", "<%=contextPath%>/talentsRecommend/editView?id=" + id , 600, 750);
	}
	function showdemand(id) {
		openwindow("查看招聘需求", "<%=contextPath%>/demandEnterprise/detailView?id=" + id, 600, 750);
	}
	function showtalents(id) {
		window.location.href="<%=contextPath%>/resume/detailView?id=" + id;
	}
	function downreport(file){
		var doc = '<%=contextPath%>'+file; 
		var triggerDownload = $("<a>").attr("href", doc).attr("download", doc).appendTo("body"); 
   	    triggerDownload[0].click(); 
        triggerDownload.remove();
	}
	function showcontact() {
		openwindow("查看企业联系人", "<%=contextPath%>/company/contactList?companyId=" + companyId, 1080, 750);
	}
	function addfeedback(recommendId,talentsId) {
		swal({ 
			title: "该人才是否合适？", 
			type: "warning", 
			showCancelButton: true, 
			confirmButtonColor: "#DD6B55", 
			confirmButtonText: "No", 
			cancelButtonText: "Yes", 
			closeOnConfirm: false, 
			closeOnCancel: false 
			}, 
			function(isConfirm) { 
				if (isConfirm) { 
					swal({
   		    			title:"即将进入下一环节",
   		    			text: "1秒后自动关闭。", 
   		    			timer: 1000, 
   					    showConfirmButton: false
   		    		});
					openwindow("反馈推荐结果", "<%=contextPath%>/recommendResult/addView?recommendId=" + recommendId +"&companyId=" + companyId, 600, 500);
					} else{ 
						swal({
       		    			title:"即将进入下一环节",
       		    			text: "1秒后自动关闭。", 
       		    			timer: 1000, 
       					    showConfirmButton: false
       		    		});
						openwindow("添加沟通记录", "<%=contextPath%>/demandCommunicate/addView?talentsId=" + talentsId+"&recommendId=" + recommendId +"&companyId=" + companyId+"&demandId="+id, 500, 550);
						
					} 
				})
	}
	function openrecord(recommendId) {
		openwindow("查看沟通记录", "<%=contextPath%>/demandCommunicate/list?recommendId=" + recommendId, 1080, 550);
	}
	function openresult(recommandId) {
		openwindow("查看推荐结果", "<%=contextPath%>/recommendResult/resultView?recommandId=" + recommandId +"&companyId=" + companyId, 800, 600);
	}
	function timeline(id) {
		openwindow("沟通时间轴","<%=contextPath%>/talentsRecommend/timeLine?id="+id,1080,550);
	}
	function openwindow(title,url,width,height){
	 var diag = new Dialog();
	 diag.Drag=true;
	 diag.Title =title;
	 diag.URL = url;
	 diag.Width = width;
	 diag.Height = height;
	 diag.CancelEvent = function(){ //关闭事件
		document.location.reload();
		diag.close();
	 };
	 diag.show();
}//是通过这个方法打开的子窗体
	</script>
</body>
</html>

